<template>
  <div class="serviceprofitContent">
    <div class="serviceprofitTitle">
      <div class="customerTitle">海川医药客服盘盈亏{{ dateTransfer }}日报</div>
      <!-- <div class="searchBtn">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="date"
        >
        </el-date-picker>
        <el-button type="success" @click="handleserviceProfit">搜索</el-button>
      </div> -->
    </div>
    <div class="serviceprofitTable">
      <el-table
        :data="tableData"
        style="width: 100%"
        :cell-style="tableCellStyle"
        :header-cell-style="{
          background: '#1890ff',
          textAlign: 'center',
          color: '#fff',
          fontSize: '16px',
          fontWeight: 'bold',
        }"
      >
        <el-table-column label="零货库" align="center">
          <el-table-column
            prop="lhkPkje"
            label="盘亏金额"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.lhkPkje"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="lhkTms"
            label="条目数"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.lhkTms"></el-input>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="中药库" align="center">
          <el-table-column
            prop="zykPkje"
            label="盘亏金额"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.zykPkje"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="zykTms"
            label="条目数"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.zykTms"></el-input>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="整件库" align="center">
          <el-table-column
            prop="zjkPkje"
            label="盘亏金额"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.zjkPkje"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="zjkTms"
            label="条目数"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.zjkTms"></el-input>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="医院部" align="center">
          <el-table-column
            prop="yybPkje"
            label="盘亏金额"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.yybPkje"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="yybTms"
            label="条目数"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.yybTms"></el-input>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="不合格库" align="center">
          <el-table-column
            prop="bhgkPkje"
            label="盘亏金额"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.bhgkPkje"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="bhgkTms"
            label="条目数"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.bhgkTms"></el-input>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="LOST库" align="center">
          <el-table-column
            prop="lostPkje"
            label="盘亏金额"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.lostPkje"></el-input>
            </template>
          </el-table-column>
          <el-table-column
            prop="lostTms"
            label="条目数"
            align="center"
            width="100px"
          >
            <template slot-scope="scope">
              <el-input v-model="scope.row.lostTms"></el-input>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column
          prop="zpkje"
          label="总盘亏金额"
          align="center"
          width="110px"
        >
          <template slot-scope="scope">
            <el-input v-model="scope.row.zpkje"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="ztms" label="总条目数" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.ztms"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="bz" label="备注" align="center">
          <template slot-scope="scope">
            <el-input v-model="scope.row.bz"></el-input>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { dailyaddjdc, dailylistjdc } from "@/api/system/daily";
export default {
  props: {
    dateTransfer: {
      type: String,
    },
  },
  data() {
    return {
      dateRange: new Date().toISOString().split("T")[0],
      // 陕西海通零货条目数
      ids: null,
      systemTime: "",
      tableData: [
        {
          xrkskut: "",
          rkjs: "",
          rkzbdcl: "",
          zkcjs: "",
          zskut: "",
          ckd: "",
          ckj: "",
          dbckdcl: "",
          zyscs: "",
          zysce: "",
        },
      ],
    };
  },
  mounted() {
    // 创建一个 Date 对象
    const currentDate = new Date();
    // 获取当前年份
    const year = currentDate.getFullYear();
    // 获取当前月份（注意：月份是从 0 开始计数的，所以需要加 1）
    const month = currentDate.getMonth() + 1;
    // 获取当前日期
    const day = currentDate.getDate();
    // 打印年月日
    this.systemTime = `${year}年${month}月${day}日`;
  },
  beforeDestroy() {},
  methods: {
    // 设置表格边框颜色
    tableCellStyle() {
      return "border-color: #181616";
    },
    handleserviceProfit() {
      dailylistjdc({ rbSj: this.dateTransfer }).then((res) => {
        const { data } = res;
        if (data) {
          this.tableData[0] = { ...this.tableData[0], ...data };
        }
      });
    },
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        // if (index === 6 || index === 7 || index === 8) {
        //   sums[index] = "";
        //   return;
        // } else if (index === 0) {
        //   sums[index] = "合计";
        //   return;
        // }
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
        const values = data.map((item) => Number(item[column.property]));
        if (
          !values.every((value) => isNaN(value)) &&
          column.property != "rkzbdcl"
        ) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[index] += "";
        }
      });

      return sums;
    },
  },
};
</script>

<style lang="scss" scoped>
.serviceprofitContent {
  width: 100%;
  height: 100%;
  ::v-deep .el-table__body-wrapper {
    border: 1px solid #181616;
  }
  .el-table--group::after,
  .el-table--border::after {
    background-color: #181616;
  }
  ::v-deep .el-table--enable-row-hover .el-table__body tr:hover > td {
    background-color: transparent;
  }
  ::v-deep .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 100%;
  }
  // ::v-deep .el-input--prefix .el-input__inner {
  //   border: none;
  // }
  ::v-deep .el-table tr {
    height: 70px;
  }
  .beakageRate {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .serviceprofitTitle {
    width: 100%;
    text-align: center;
    .customerTitle {
      width: 100%;
      font-size: 30px;
      font-weight: 700;
      margin: 30px 0 20px 0;
    }
    ::v-deep .el-button--success {
      height: 36px;
      margin-left: 30px;
    }
  }
  .serviceprofitTable {
    width: 90%;
    margin-top: 20px;
    ::v-deep .el-table__footer-wrapper tbody td.el-table__cell {
      background: #75d561;
      color: #ff4800;
      font-weight: 700;
      font-size: 16px;
    }
    ::v-deep .el-input__inner {
      height: 65px;
      line-height: 65px;
      border: none;
      text-align: center;
      color: #000000;
      width: 100%;
    }
  }
}
</style>